﻿using System;
using System.Text;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Pages_HomePage_detailDesign : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            getDesign();
            GetImage();
        }
    }

    private void getDesign()
    {
        Design d = new Design();
        CommonBUS com = new CommonBUS();
        string id = Request.QueryString["PID"];
        d = com.getDetailDeisgn(id);
        lblShowName.Text = d.Name;
        lblShowPostdate.Text = Convert.ToDateTime(d.PostDate).ToString("MM/dd/yyyy");
        lblShowQuatation.Text = d.Quotation;
        lblShowStudent.Text = d.St.Fullname;
        lblShowCompetition.Text = d.Com.Name;
        txtShowDescription.Text = d.Description;
        imgDesign.ImageUrl = "~/Images/Design/" + d.DesignImage;
    }

    private void GetImage()
    {
        CommonBUS com = new CommonBUS();        
        collectionPager.PageSize = 4;
        collectionPager.DataSource = com.GetImg().DefaultView;
        collectionPager.BindToControl = dtListImg;
        dtListImg.DataSource = collectionPager.DataSourcePaged;
    }

    public static string Filter(string _txt)
    {
        try
        {
            StringBuilder strBuilder = new StringBuilder();
            strBuilder.Insert(0, _txt);
            if (strBuilder.Length > 50)
            {
                return strBuilder.ToString().Substring(0, 290) + "...";
            }
            else
            {
                return strBuilder.ToString();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
}